package com.yls.except.util;


import com.cloopen.rest.sdk.CCPRestSDK;
import com.rong.AccountConstant;
import com.rong.ApiHttpClient;
import com.rong.models.SdkHttpResult;
import org.apache.log4j.Logger;

import java.util.HashMap;
import java.util.Map;

public class PhoneMessage {
	
	
	public static Map<String, Object> phonesendmessage(String yzcode, String phone, String type) {
		HashMap<String, Object> result = null;
		CCPRestSDK restAPI = new CCPRestSDK();
		String mbid = AccountConstant.OTHERCODEID;
//		if ("1".equals(type))
//			mbid = AccountConstant.SETPAYPWDCODEID;
//		else
//			mbid = AccountConstant.OTHERCODEID;
		restAPI.init(AccountConstant.INITURL, AccountConstant.INITROOT);// 初始化服务器地址和端口，格式如下，服务器地址不需要写https://
		restAPI.setAccount(AccountConstant.ACCOUNTID, AccountConstant.ACCOUNTTOKEN);// 初始化主帐号和主帐号TOKEN
		restAPI.setAppId(AccountConstant.APPID);// 初始化应用ID
		result = restAPI.sendTemplateSMS(phone, mbid, new String[]{yzcode, "5"});
//		result = restAPI.sendTemplateSMS("号码1,号码2等","模板Id" ,new String[]{"模板内容1","模板内容2"});
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("code", result.get("statusCode"));
		if ("000000".equals(result.get("statusCode"))) {
			map.put("msg", "获取成功");
		} else {
			map.put("msg", result.get("statusMsg"));
			Logger log = Logger.getLogger(PhoneMessage.class);
			log.debug(result.get("statusMsg"));
		}
		return map;
	}

	public static void main(String[] args) {
		System.out.println(phonesendmessage("132123","13486755666","1"));
//		System.out.println(phonesendmessage("132123","18223960536","1"));
	}
}